using System;
using Castle.ActiveRecord;
using CosyTrade.Data;

namespace CosyTrade.Distribution
{
    [AddPropertyChangedNotifyInterface, PropertyChangedNotify]
    [Serializable, ActiveRecord("tabAddress")]
    public class Address : BusinessObject 
    {
        private readonly Guid primaryKey = Guid.NewGuid();
        private string zipCode;
        private string addressInfo;
        private RegionBase province;
        private RegionBase city;
        private RegionBase region;
        private string memo;

        [PrimaryKey(PrimaryKeyType.Assigned, "ROWGUID", 
            Access = PropertyAccess.NosetterCamelcase)]
        public override Guid PrimaryKey
        {
            get { return primaryKey; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Property]
        public string ZipCode
        {
            get { return zipCode; }
            set { zipCode = value; }
        }

        [Property]
        public string AddressInfo
        {
            get { return addressInfo; }
            set { addressInfo = value; }
        }

        [BelongsTo("ProvinceGuid")]
        public RegionBase Province
        {
            get { return province; }
            set { province = value; }
        }

        [BelongsTo("CityGuid")]
        public RegionBase City
        {
            get { return city; }
            set { city = value; }
        }

        [BelongsTo("RegionGuid")]
        public RegionBase Region
        {
            get { return region; }
            set { region = value; }
        }

        [Property]
        public string Memo
        {
            get { return memo; }
            set { memo = value; }
        }
    }

    [Serializable]
    public class AddressEditModule
    {
        private bool isNew;
        private bool isDelete;
        private bool isUpdate;
        private Guid objectId;

        public bool IsNew
        {
            get { return isNew; }
            set { isNew = value; }
        }

        public bool IsDelete
        {
            get { return isDelete; }
            set { isDelete = value; }
        }

        public bool IsUpdate
        {
            get { return isUpdate; }
            set { isUpdate = value; }
        }

        public Guid ObjectId
        {
            get { return objectId; }
            set { objectId = value; }
        }
    }
}